from codex import * from time import sleep import random display.print('press A to roll') display.print('press B to stop rolling') sleep(1) display.clear() delay = 1 numbers = [ "1", "2", "3", "4", "5", "6"] def roll_animation(random): delay = .5 index = 0 loops = 0 while loops < 0: loops = loops + 1 display.draw_text(numbers[index]) sleep(delay) index = index + 1 if index == 6: index = 0 def show_random_roll(): num = random.randrange(6) display.draw_text(numbers[num], scale=20, x=70, y=40) sleep(delay) display.clear() while True: pixels.set(0, random.choice(COLOR_LIST)) pixels.set(1, random.choice(COLOR_LIST)) display.draw_text('Rolling', scale=3, x=0, y=40) sleep(.3) pixels.set(2, random.choice(COLOR_LIST)) pixels.set(3, random.choice(COLOR_LIST)) display.clear() if buttons.was_pressed(BTN_A): roll_animation(30) show_random_roll() if buttons.was_pressed(BTN_B): display.print("Rolling over") break